home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: [] overload..(newbie in distress)
- Date: 22 Jan 1996 23:50:45 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan22185045@g7240065.bridge.bst.bls.com>
- References: <DLGppJ.31C@undergrad.math.uwaterloo.ca>
- <Robert.Lendvai-2101960118330001@129.170.80.94>
- <4dtuam$hf4@news.xmission.com>
- <ALUN.CHAMPION.96Jan22143422@g7240065.bridge.bst.bls.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: Alun.Champion@bridge.bst.bls.com's message of 22 Jan 1996
- 19:34:22 GMT
-
- In article <ALUN.CHAMPION.96Jan22143422@g7240065.bridge.bst.bls.com> Alun.Champion@bridge.bst.bls.com (Alun Champion) writes:
-
- : In article <4dtuam$hf4@news.xmission.com> tknarr@xmission.com ( Todd Knarr ) writes:
-
- : : tthiraku@landen.math.uwaterloo.ca (Thanou Thirakul) wrote:
- : :> A[5] = val; // store val into the fifth node of a linklist.
- : :> val = A[5] ; // returns the value of the fifth node of a linklist.
-
- : T& operator [] (int index);
- : T operator [] (int index) const;
-
- : : It involves the return value of the operator[]() function. If it
- : : returns a reference, you can use it on the left side of the assignment.
- : : If it returns a non-reference, you can't.
-
- : A reference can also be used on the right of an assignment also.
-
- : Does anyone have any good reasons or references as why you should define the
- : second of the two operator []'s if you provide the first ?
-
- For const list of course, dopey sod. ;')
- Oops, guess I didn't long enough on this one, but still doesn't answer the
- question below.
-
- : And if it is necessary what is the argument against
-
- : const T& operator [] (int index) const;
-
- : instead ?
-
- Regards
-
- -A.
- --
- | A.Champion |
-